﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using PAMD.Database.Model;

namespace PAMD.Controllers.Extension
{
    public static class EntityExtension
    {
        public static List<SelectListItem> ToSelectListItems<T>
            (this IEnumerable<T> baseEntities) where T : KeyValue
        {
            return baseEntities.Select(entity => new SelectListItem {Value = entity.Id, Text = entity.Text}).ToList();
        }
    }
}